package com.futureweaver.controller;

import com.futureweaver.domain.Employee;
import com.futureweaver.request.vo.EmpQueryByDeptIdOrNoVo;
import com.futureweaver.service.EmployeeService;
import com.futureweaver.request.vo.LoginVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/employee")
public class EmployeeController {
    @Autowired
    private EmployeeService service;

    @RequestMapping("/login")
    @ResponseBody
    public boolean login(@RequestBody LoginVO vo) {
        return service.login(vo);
    }

    @RequestMapping("/query_by_dept_id_or_no")
    @ResponseBody
    public List<Employee> queryByDeptIdOrNo(@RequestBody EmpQueryByDeptIdOrNoVo vo) {
        return service.queryByDepartment(vo.getDeptId(), vo.getDeptNo());
    }

    @RequestMapping("/query_by_dept_id_and_level_id")
    @ResponseBody
    public List<Employee> queryByDeptIdAndLevelId(@RequestBody Map<String, Object> vo) {
        return service.queryByDeptIdAndLevelId(
                (String) vo.get("deptId"),
                (String) vo.get("levelId"));
    }
}
